package com.vincent.kdp.presenter;

import com.vincent.kdp.bean.MyCraftBean;
import com.vincent.kdp.bean.MyMetalColorBean;
import com.vincent.kdp.bean.MySeriesAdapterBean;
import com.vincent.kdp.bean.QualityBean;
import com.vincent.kdp.contract.SelectContract;
import com.vincent.kdp.http.RequestCallBack;
import com.vincent.kdp.ui.fragment.repository.CommodityRepository;

/**
 * Created by jingjing on 2017/3/21.
 */

public class SelectPresenter implements SelectContract.Presenter {

    private SelectContract.View view;
    private CommodityRepository mRepository;

    public SelectPresenter(SelectContract.View view) {
        this.view = view;
        mRepository = new CommodityRepository();
    }

    /**
     * 获取材质列表
     */
    @Override
    public void reqSearch() {
        mRepository.reqQualityList(new RequestCallBack() {
            @Override
            public void onSuccess(Object object) {
                QualityBean outPut = (QualityBean) object;
                if (view != null) {
                    if (outPut.getData() != null) {
                        view.initSelectSearch(outPut.getData());
                    }
                }
            }

            @Override
            public void onFalse(String msg) {

            }
        });
    }

    /**
     * 获取系列
     */
    @Override
    public void reqSeries() {
        mRepository.reqSeriesList(new RequestCallBack() {
            @Override
            public void onSuccess(Object object) {
                MySeriesAdapterBean outPut = (MySeriesAdapterBean) object;
                if (view != null) {
                    if (outPut.getData() != null) {
                        view.initSeriesSearch(outPut.getData());
                    }
                }
            }

            @Override
            public void onFalse(String msg) {

            }
        });
    }

    /**
     * 获取工艺列表
     */
    @Override
    public void reqCraft(String id,String styleId) {
        mRepository.reqCraftList(id,styleId, new RequestCallBack() {
            @Override
            public void onSuccess(Object object) {
                System.out.println("cccccccccccccccccccccccccccc");
                MyCraftBean outPut = (MyCraftBean) object;
                System.out.println("c55555555555555"+outPut.getData().size());
                if (view != null) {
                    if (outPut.getData() != null) {
                        System.out.println("c55555555555555"+outPut.getData().size());
                        view.initCraftSearch(outPut.getData());
                    }
                }
            }

            @Override
            public void onFalse(String msg) {

            }
        });
    }

    /**
     * 获取金属色列表
     */
    @Override
    public void reqMetalColor(String id) {
        mRepository.reqMetalColorList(id, new RequestCallBack() {
            @Override
            public void onSuccess(Object object) {
                MyMetalColorBean outPut = (MyMetalColorBean) object;
                if (view != null) {
                    if (outPut.getData() != null) {
                        view.initMetalColorSearch(outPut.getData());
                    }
                }
            }

            @Override
            public void onFalse(String msg) {

            }
        });
    }


}
